
from django.db import models
from denorm import AggregateField, MirrorField


class Agg(models.Model):
    
    children_count = AggregateField("AggFKSource", "count", fk="parent")
    integer_count = AggregateField("AggAllSource", "count", all=True)


class AggFKSource(models.Model):
    
    name = models.CharField(max_length=255)
    parent = models.ForeignKey(Agg, blank=True, null=True)


class AggAllSource(models.Model):
    
    integer = models.IntegerField()


class MirrorSource(models.Model):
    
    name = models.CharField(max_length=255)


class Mirror(models.Model):
    
    other = models.ForeignKey(MirrorSource)
    other_name = MirrorField("other", "name")



